<template>
	<view class="container">
		<view class="textarea-wrapper">
			<textarea v-model="feedbackText" placeholder="请输入您的问题"></textarea>
		</view>
		<button @click="submitFeedback()">提交反馈</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				feedbackText: '' // 用户填写的反馈内容
			};
		},
		methods: {
			submitFeedback() {
				// 获取用户填写的反馈内容
				const {
					feedbackText
				} = this;
				var formData = {
					title: '',
					context: feedbackText,
					files: '',
				};
				var jsonData = JSON.stringify(formData); //将表单数据转换成json类型数据
				uni.request({
				  url: 'http://localhost:8081/user/issue',
				  data: jsonData,
				  header: {
				    'Content-Type': 'application/json', //自定义请求头信息
				    'Access-Control-Allow-Headers': 'appId',
				    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
				    'Access-Control-Max-Age': 86400,
				    'Authorization': '' + wx.getStorageSync('sessionID')
				  },
				  method: 'POST',
				  success: res => {
				    console.log(res);
						console.log('反馈成功');
				  },
					fail: res => {
						console.log(res);
						console.log('反馈失败');
					}
				});
				// 执行反馈提交的逻辑，比如发送请求给后端保存反馈内容

				// 模拟提交成功，弹出提示信息
				uni.showToast({
					title: '反馈提交成功',
					icon: 'success'
				});

				// 清空文本框
				this.feedbackText = '';
			}
		}
	};
</script>

<style>
	.container {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding: 20rpx;
	}

	.textarea-wrapper {
		width: 90%;
		margin-bottom: 20rpx;
	}

	textarea {
		position: relative;
		top: 50rpx;
		width: 94%;
		height: 500rpx;
		margin-bottom: 20rpx;
		border: 2rpx solid #ccc;
		/* 设置边框 */
		padding: 20rpx;
		border-radius: 10rpx;
	}

	button {
		top: 150rpx;
		width: 80%;
		height: 60rpx;
		line-height: 60rpx;
		text-align: center;
		background-color: #fafdca;
		color: #282c35;
		border-radius: 4rpx;
	}
</style>